import time

from selenium import webdriver

from selenium.webdriver.chrome.service import Service
# from selenium.webdriver.edge.service import Service

from selenium.webdriver.common.by import By
from webdriver_manager.chrome import ChromeDriverManager

#编写自动化脚本，具体步骤

# # 1. 打开浏览器
# ChromeIns=ChromeDriverManager().install()
# # 创建谷歌浏览器驱动对象
# driver=webdriver.Chrome(service=Service(ChromeIns))
# # 2. 输入网址
# driver.get("https://www.baidu.com")
# # 3. 找到输入框
# driver.find_element(By.CSS_SELECTOR, "#kw").send_keys("迪丽热巴")
#
# # 4. 点击“百度一下”
# driver.find_element(By.CSS_SELECTOR, "#su").click()
# time.sleep(2)
#
# # 5. 关闭浏览器
# driver.quit()


# 1. 打开浏览器
ChromeIns=ChromeDriverManager().install()
# 创建谷歌浏览器驱动对象
driver=webdriver.Chrome(service=Service(ChromeIns))

driver.get("https://www.baidu.com")

driver.find_element(By.CSS_SELECTOR, "#kw").send_keys("雷军")
# ele = driver.find_element(By.CSS_SELECTOR, "#hotsearch-content-wrapper > li:nth-child(1) > a > span.title-content-title")
# ele.click()

time.sleep(2)

driver.quit()
